import { defineStore } from 'pinia'
import type { Menu } from '@/router/type'
interface menuState {
  menu: Menu[]
}

export const useMenuStore = defineStore('menu', {
  state: (): menuState => {
    return {
      menu: []
    }
  },
  getters: {
    getMenu(): any {
      return this.menu
    }
  },
  actions: {
    addMenu(): any {
      const sessionMenu = JSON.parse(sessionStorage.getItem('menu')!)
      this.menu = sessionMenu
    },
    removeMenu() {
      sessionStorage.removeItem('menu')
      this.menu = []
    }
  }
})
